LONDON | MAY2025 | STRUCTURING AND TESTING DATA | SPRING 2 JESUS DEL MORAL#537
LONDON | MAY2025 | STRUCTURING AND TESTING DATA | SPRING 2 JESUS DEL MORAL#537delmorallopez wants to merge 5 commits intoCodeYourFuture:mainfrom
Conversation
Amundeep-Dhaliwal
left a comment
There was a problem hiding this comment.
Hello Jesus, thanks for your patience and for completing this work.
Have made some comments on the code, all the solutions look good to me.
| // =============> write your new code here | ||
|
|
||
| function capitalise(str) { | ||
| let capitalised = `${str[0].toUpperCase()}${str.slice(1)}`; |
|
|
||
| function multiply(a, b) { | ||
| console.log(a * b); | ||
| return(a * b); |
| function sum(a, b) { | ||
| return; | ||
| a + b; | ||
| return(a+b) |
There was a problem hiding this comment.
Yes this is correct.
In JS lines can be terminated with a semicolon.
| // const num = 103; | ||
|
|
||
| function getLastDigit() { | ||
| function getLastDigit(num) { |
There was a problem hiding this comment.
Yes this is a good parameter name.
| } No newline at end of file | ||
| const bmi = 0 | ||
|
|
||
| height = height * height; |
There was a problem hiding this comment.
Yes this solution is correct, perhaps in the future we can avoid reusing variables?
It makes the code more confusing, it is good practice to use new variables:
let heightSquared = height * height;
| return str | ||
| .trim() // Remove leading/trailing whitespace | ||
| .toUpperCase() // Convert to uppercase | ||
| .replace(/\s+/g, '_'); // Replace spaces with underscores |
There was a problem hiding this comment.
This is a nice use of regular expressions here and I like your helpful comments.
Well done.
| .substring(paddedPenceNumberString.length - 2) | ||
| .padEnd(2, "0"); | ||
|
|
||
| console.log(`£${pounds}.${pence}`); |
There was a problem hiding this comment.
This function behaves as expected.
Are we supposed to use a return statement instead of a console.log command?
We have a console.log command on line 33 as well.
|
|
||
| // d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer | ||
| // =============> write your answer here | ||
| // The value assigned last time we called Pad is 1, but the return is 01 |
There was a problem hiding this comment.
These answers are logically correct.
Be mindful of what the question is asking here,
We can rephrase the last part of the question as:
`explain why the remainingSeconds variable returns the value of 01 when inputted into the pad function?'
The return value of pad is not being asked for here.
|
|
||
| // e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer | ||
| // =============> write your answer here | ||
| // The value is returned is 01 |
There was a problem hiding this comment.
Explain questions ask for verbal reasoning for the reason that the return value is what it is.
Your answer could be something along the lines of:
The return value when pad is called with the input of 1 is 01 because we zero pad the front of the the number so it is 2 digits.
I have committed my files one by one, on purpose, and for a reason
I have titled my PR with REGION | COHORT_NAME | FIRST_NAME LAST_NAME | PROJ_NAME
I have tested my changes
My changes follow the style guide
My changes meet the requirements of this task
SPRINT 2 with 5 commits